#include<Servo.h>//实现按钮控制电机

Servo myServo[2];
int dataIndex=0;
int pos=80;//0正转最快 90 停转 180 反转最快
void setup() {
  // put your setup code here, to run once:
  myServo[0].attach(3);
  myServo[0].write(90);
  myServo[1].attach(5);
  myServo[1].write(90);
  pinMode(13,INPUT_PULLUP);
  Serial.begin(9600);
  Serial.println("input Serial data:");
}

void loop() {
  // put your main code here, to run repeatedly:
  short st=digitalRead(13);
  if(st==0)
  {
    myServo[0].write(pos);
    myServo[1].write(pos);
  }
  else 
  {
    myServo[0].write(90);
    myServo[1].write(90);
  }
  //Serial.println(st);
  delay(10);
}
